package com.rchat.pocmini.activity.invitefriendtogroup;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.rchat.pocmini.R;
import com.rchat.pocmini.bean.UserNoInGroupBean;

import java.util.ArrayList;

/**
 * Created by ljd on 2017/9/7.
 */

public class SelectedMemberAdapter extends BaseAdapter{

    private LayoutInflater inflater;
    private ArrayList<UserNoInGroupBean.DataBean.UsersBean.UserBean> data;

    public SelectedMemberAdapter(Context context, ArrayList<UserNoInGroupBean.DataBean.UsersBean.UserBean> data){
        this.data = data;
        inflater = LayoutInflater.from(context);
    }


    @Override
    public int getCount() {
        return data==null?0:data.size();
    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        final ViewHolder holder;
        if (null == convertView) {
            convertView = inflater.inflate(R.layout.search_hlistview_item, null);
            holder = new ViewHolder();
            holder.tvDisplayName = (TextView) convertView.findViewById(R.id.textView1);
            holder.ivHead = (ImageView) convertView.findViewById(R.id.imageView1);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.tvDisplayName.setText(data.get(position).getDisplay());
        return convertView;
    }

    private static class ViewHolder{
        private ImageView ivHead;
        private TextView tvDisplayName;
    }
}
